package cn.edu.dgut.sai.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Primary;

/**
 * @author Sai
 * Created by Sai on 2019/9/6.
 */
//@Configuration
public class TestConfig {

    @Bean("sai")
    @Sai
    public AccountRepository createJdbcAccountRepo() {
        return new JdbcAccountRepository();
    }

//    @Bean
//    public TransferService createTransferSvc(AccountRepository accountRepository) {
//        return new TransferServiceImpl(accountRepository);
//    }

    @Bean
    /*
        @DependsOn 依赖某个名字的Bean
     */
    @DependsOn("sai")
    public TransferService createTransferSvc() {
        return new TransferServiceImpl(createJdbcAccountRepo());
    }

//    @Bean
//    @Primary
//    public TransferService createTransferSvc2() {
//        return new TransferServicesImpl2();
//    }
}
